Skip to content

feat(bitcoin-wallet-snap): add batch proof-of-ownership signing - #266

Open
hmalik88 wants to merge 15 commits into
mainfrom
hm/mul-2184
Open

feat(bitcoin-wallet-snap): add batch proof-of-ownership signing#266
hmalik88 wants to merge 15 commits into
mainfrom
hm/mul-2184

Conversation

@hmalik88

@hmalik88 hmalik88 commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Explanation

This PR adds signProofOfOwnershipBatch support to the Bitcoin Wallet Snap.
The new method lets MetaMask request proof-of-ownership signatures for multiple Bitcoin accounts in one Snap RPC call. The response preserves input order and returns per-item success/error results, so one invalid account or message does not fail the entire batch.

References

N/A

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

@hmalik88
hmalik88 marked this pull request as ready for review September 4, 2026 15:16
@hmalik88
hmalik88 requested a review from a team as a code owner September 4, 2026 15:17
@hmalik88
hmalik88 deployed to default-branch September 4, 2026 15:17 — with GitHub Actions Active
@hmalik88

hmalik88 commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-preview

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Preview builds have been published. Learn how to use preview builds in other projects.

Expand for full list of packages and versions.
@metamask-previews/bitcoin-wallet-snap@2.0.1-preview-ad85ae00
@metamask-previews/snap-networks-utils@1.0.0-preview-ad85ae00
@metamask-previews/solana-wallet-snap@6.0.0-preview-ad85ae00
@metamask-previews/stellar-wallet-snap@0.1.0-preview-ad85ae00
@metamask-previews/tron-wallet-snap@3.2.0-preview-ad85ae00

Comment thread packages/bitcoin-wallet-snap/src/handlers/RpcHandler.ts Outdated
Comment on lines +583 to +594
const { index, accountId } = signingRequests[
signingRequestIndex
] as (typeof signingRequests)[number];
const { error } = signedMessage as { error?: string };

if (error !== undefined) {
results[index] = { accountId, error };
return;
}

const { signature } = signedMessage as { signature: string };
results[index] = { accountId, signature };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar comments than for Solana here: #256 (comment)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread packages/bitcoin-wallet-snap/src/handlers/RpcHandler.ts Outdated
Comment thread packages/bitcoin-wallet-snap/src/use-cases/AccountUseCases.ts Outdated
Comment thread packages/bitcoin-wallet-snap/src/use-cases/AccountUseCases.ts
'Failed to sign message',
{
id: account.id,
message,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we are logging the message being signed in Solana? 🤔 not sure we should have it here either, WDYT? Yes it's supposed to be a public message, but just in case (future-proofing)

Comment on lines +508 to +510
const results: SignProofOfOwnershipBatchResponse['results'] = new Array(
items.length,
);

@montelaidev montelaidev Sep 11, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should use the length of uniqueAccountIds here because there may be duplicates.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs to stay as items.length. The response is per input item and preserves input order, so duplicate account IDs still need duplicate result slots.

message: string;
}[] = [];

items.forEach(({ accountId, message }, index) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just use the array of unique id here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uniqueAccountIds is only for fetching accounts; it drops the item index and message, which we need for validation/signing and for putting results back in the right positions.

@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants